<?php
namespace core;

class ContainerBase extends Container 
{

	protected $provider = [];

	public function __construct()
	{
		// 方法一
		// $callback = function ($provider) {
		// 	$obj = new $provider;
		// 	return $obj->serviceProvider($this);
		// };

		// 方法二
		$callback = function ($provider) {
			$obj = new $provider;
			return $this->providerRegister($obj);
		};

		array_walk($this->provider, $callback);
	}

	// 获取所有供应者
	public function getProvider()
	{
		return $this->provider;
	}


	public function __get($property)
	{
		// if (isset($this->provider[$property])) {
		// 	return $this;
		// }

		$obj = $this->offsetGet($property);

		return $obj;
	}

}

?>